#ifndef ADDON_MANAGER_PRVIATE_H
#define ADDON_MANAGER_PRIVATE_H
#include <qobject.h>
#include <qtreewidget.h>
#include "AddonManager.h"
#include "ui_addonPanel.h"

class AddonManagerPrivate : public QObject
{
	Q_OBJECT
	DECLARE_PUBLIC(AddonManager)
public:
	AddonManagerPrivate(AddonManager* ptr);

	AddonPackage* createPackageFromFile(const QString& file);
	bool addPackageFromDir(const QString& dir);

	AddonPackage* createPackage(const ModuleInfo& info);
	void addPackage(AddonPackage* package);

	QStringList getPackageNameList()const;
	AddonPackage* getPackageByName(const QString& name);

	bool process(const QMouseEvent& event);
	bool process(const QKeyEvent& event);
    bool process(const QWheelEvent& event);

	//void receivedMessage(const AddonMessage& message);
	//void sendMessage(const AddonMessage& message);

	ModuleInfo getAddonInfo()const;
	Ui::AddonPanel getAddonPanel(){return ui;}
	QTreeWidget* getTreeWidget()const{return ui.treeWidget;}
private:
	QTreeWidgetItem* getTreeItemByTypeName(const QString& name);
private:
	ModuleInfo moduleInfo;
	QMap<QString,AddonPackage*> packages;

	QWidget* addonPanel = nullptr;
	Ui::AddonPanel ui;
	QMap<QString,QTreeWidgetItem*> addonTypeList;
};

#endif